import {createRouter, createWebHashHistory} from 'vue-router'

const registerRoute = () => {
  const routerList  = []
  const modules = import.meta.globEager('./*/*.rou.js')
  for (const val of Object.values(modules)){
    routerList.push(val.default)
  }
  return routerList.flat()
}

import basics from './basics'
import lesson from "./lesson";

const modules = [
  basics
]

const router = createRouter({
  history: createWebHashHistory(),
  routes: [
    {
      path: '/',
      redirect: {
        name: 'Login'
      }
    },
    {
      path: '/login',
      name: 'Login',
      meta: {
        hidden: true
      },
      component: () => import('../views/login/login.vue')
    },
    ...modules,
    {
      path: '/:catchAll(.*)',
      redirect: '/404',
      hidden: true,
      meta: {
        hidden: true
      }
    }
  ]
})
router.beforeEach((to, from, next) => {
  console.log('router.beforeEach to', from)
  next()
})

export default router